# try something like
import datetime

try:
    from gluon.contrib.gql import *        # if running on Google App Engine
    from google.appengine.api import mail
except:
    db=SQLDB('sqlite://storage.db')         # if not, use SQLite or other DB
else:
    db=GQLDB()                              # connect to Google BigTable
    session.connect(request,response,db=db) # and store sessions there
    #session.forget()

TOP_MESSAGE="(contact form)"
VALUE="(default message)"

db.define_table('message',
   SQLField('your_name',requires=IS_NOT_EMPTY()),
   SQLField('your_email',requires=IS_EMAIL()),
   SQLField('your_message','text',default=VALUE),
   SQLField('timestamp',default=str(datetime.datetime.now())))

db.define_table('recipient',
   SQLField('name',requires=IS_NOT_EMPTY()),
   SQLField('email',requires=IS_EMAIL()))

def email_user(sender,text,subject="Krasimira.net client notice"):    
    fromaddr=sender
    toaddrs=[x.email for x in db().select(db.recipient.ALL)]
    message=mail.EmailMessage()
    message.sender='krasimira@krasimira.net'
    message.sender=subject
    message.to=', '.join(toaddrs)
    message.body=text
    message.send()

try:
    if not db(db.recipient.email=="krasimira@krasimira.net").select():
      db.recipient.insert(name="Shushu", email="krasimira@krasimira.net")
except SyntaxError: 
    pass
